package com.syedu.day15.homework;

/**
 * description：数字线程
 * @author Administrator
 * @date 2022/4/2 14:02
 */
public class NumberThread implements Runnable {

    private Object lock;

    public NumberThread(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            for (int i = 1; i <= 26; i++) {
                System.out.print(i * 2 - 1);
                System.out.print(i * 2);
                try {
                    lock.notifyAll();
                    if (i != 26) {
                        lock.wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}